# -*- coding: utf-8 -*-
"""Create an application instance."""
import sys
import gevent.monkey
gevent.monkey.patch_all()
from flask.helpers import get_debug_flag
from walle.app import create_app
from walle.config.settings_dev import DevConfig
from walle.config.settings_test import TestConfig
from walle.config.settings_prod import ProdConfig

CONFIG = DevConfig if get_debug_flag() else ProdConfig
if len(sys.argv) > 2 and sys.argv[2] == 'test':
    CONFIG = TestConfig
app, socketio = create_app(CONFIG)

if __name__ == '__main__':
    if socketio:
        socketio.run(app, debug=CONFIG.DEBUG, host=CONFIG.HOST, port=CONFIG.PORT)
    else:
        app.run()
